package cx.mybatis.io;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

/**
 * @Author:cxy
 * @Date:2022/4/23 15:32
 */
public class Resources {


    public static Class<?> classForName(String className) throws ClassNotFoundException {
        return Class.forName(className);
    }

    public static Reader getResourceAsReader(String resource) throws IOException {
        return new InputStreamReader(getResourceAsStream(resource));
    }

    public static InputStream getResourceAsStream(String resource) throws IOException {
        InputStream in = Resources.class.getClassLoader().getSystemResourceAsStream(resource);
        if (null != in) {
            return in;
        }
        throw new IOException("Could not find resource " + resource);
    }
}
